<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var a = {
            name: "xiaoxin",
            age: 18,
            [Symbol.iterator]() {
                var self = this;
                return {
                    i: 0,
                    next() {
                        if (this.i == 0) {
                            this.i++;
                            return { done: false, value: self.name }
                        } else if (this.i == 1) {
                            this.i++;

                            return { done: false, value: self.age }
                        } else {
                            return {
                                done: true, value: undefined
                            }
                        }
                    }
                }
            }
        }

        console.log(...a)
        /* spread运算符（...）的结果是由目标的迭代器决定的 */
    </script>
</body>

</html>